﻿using System;
using System.Collections.Generic;
using System.Linq;
using DslModeling=global::Microsoft.VisualStudio.Modeling;
using DslDiagrams=global::Microsoft.VisualStudio.Modeling.Diagrams;
using DslValidation=global::Microsoft.VisualStudio.Modeling.Validation;

namespace Salamanca.Saml
{
    partial class StartPoint
    {
        /// <summary>Ensures that the flow is valid as far as this element is concerned.</summary>
        [DslValidation.ValidationMethod(DslValidation.ValidationCategories.Menu | DslValidation.ValidationCategories.Open | DslValidation.ValidationCategories.Save)]
        private void ValidateFlow(DslValidation.ValidationContext context)
        {
            if (TransitionFrom.Count>0)
                context.LogError(
                    Resources.SR.FlowCannotGetToStartPoint,
                    "SAML01",
                    TransitionTo.Cast<DslModeling.ModelElement>().ToArray<DslModeling.ModelElement>()
                );
            else if (TransitionTo.Count==0)
                context.LogWarning(
                    Resources.SR.StartPointNotInvolvedInFlow,
                    "SAML01",
                    this
                );
        }
    }
}
